<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Timing</title>
<script type="text/javascript">

	function timedMsg() {
		
		var t = setTimeout("alert('5 seconds!')", 5000);
	}
	
	var c = 0;
	var t;
	function startCount() {
		document.getElementById("txt").value = c;
		c = c + 1;
		t = setTimeout("startCount()", 1000);
	}
	
	function stopCount() {
		clearTimeout(t);
	}
</script>
</head>
<body>
<form>
<input type="button" value="Display timed alert box!" onClick="timedMsg()" />
<br />
<input type="button" value="Start count!" onClick="startCount()" />
<input type="text" id="txt" />
<input type="button" value="Stop count!" onClick="stopCount()" />
</form>
</body>
</html>